<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="java.text.SimpleDateFormat"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<head>
<base href="<%=basePath%>" />
<title>品牌信息相关操作</title>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
<meta http-equiv="description" content="This is my page" />
<script type="text/javascript" src="<%=basePath%>dwr/engine.js"></script>
<script type="text/javascript" src="<%=basePath%>dwr/util.js"></script>
<script type="text/javascript" src="<%=basePath%>homepage/js/common.js"></script>
<script type="text/javascript"
	src="<%=basePath%>dwr/interface/BrandInfoService.js"></script>
<link rel="stylesheet" type="text/css" media="all"
	href="<%=basePath%>sources/css/pop-up.css" />
<link rel="stylesheet" type="text/css" media="all"
	href="<%=basePath%>sources/css/general.css" />
<link rel="stylesheet" type="text/css" media="all"
	href="<%=basePath%>sources/css/reset.css" />
<link rel="stylesheet" type="text/css" media="all"
	href="<%=basePath%>sources/css/table.css" />
<link rel="stylesheet" type="text/css" media="all"
	href="<%=basePath%>sources/css/view.css" />



<script language="javascript" type="text/javascript"
	src="<%=basePath%>sources/js/WdatePicker.js"></script>
<script type="text/javascript" charset="utf-8"
	src="<%=basePath%>sources/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8"
	src="<%=basePath%>sources/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8"
	src="<%=basePath%>sources/js/ColReorder.js"></script>
<script type="text/javascript" charset="utf-8"
	src="<%=basePath%>sources/js/ColVis.js"></script>
<script type="text/javascript"
	src="<%=basePath%>sources/js/jquery.min.js"></script>
<script type="text/javascript"
	src="<%=basePath%>sources/js/flexigrid.js"></script>
<script type="text/javascript" src="<%=basePath%>sources/js/altMenu.js"></script>
<script src="<%=basePath%>sources/js/jquery-ui.js"></script>
<script src="<%=basePath%>sources/js/contextmenu.js"
	type="text/javascript"></script>



<script type="text/javascript">
    	var basePath='<%=basePath%>';
 		function selectInfo2(){
 			var biName = document.getElementById("biName").value;
    		BrandInfoService.selectInfo(biName,showResult);
 		} 
 		
 		function showResult(data){
 			var html = "";
 			if(data!=null&&data.length>0){
	 			html += "<table class='new-table' id='showId'>";
	 			html += "<tr><td>序号</td>";
	 			html += "<td>品牌名称</td>";
	 			html += "<td>操作</td></tr>";
	 			
	 			for(var i = 0;i<data.length;i++){
	 				html += "<tr><td>"+(i+1)+"</td>";
	 				html += "<td>"+data[i].brandName+"</td>";
	 				html += "<td><a href=javascript:upInfo(\'"+data[i].biId+"\')>修改</a>&nbsp;&nbsp;&nbsp;";
	 				html += "<a href=javascript:delInfo(\'"+data[i].biId+"\')>删除</a></td></tr>";
	 			}
	 			html+="</table>";
	 		
 			}
 				document.getElementById("showDiv").style.display="";
	 			document.getElementById("demo").innerHTML = html;
 			
 		}
    	
    	function upInfo(data){
    		window.open(basePath+"pages/pub_supplies_brand_change.jsp?id="+data);
    	}
    	
    	function delInfo(data){
    		if(confirm("确认删除数据？")){
    			BrandInfoService.deleteInfo(data,showResult2);
    		}else{
    			selectInfo2();
    		}
    	}
    	
    	function showResult2(data){
    		if(data==false){
    			alert("删除成功");
    			selectInfo2();
    		}else{
    			alert("删除失败");
    		}
    	}
    	
    	function addInfo(){
    		var biName = document.getElementById("biName").value;
    		if(biName!=null){
    			BrandInfoService.addInfo(biName,showResult3);
    		}
    	}
    	
    	function showResult3(data){
    		if(!data){
				alert("添加成功"); 
    			document.getElementById("biName").value = "";   		
    		}else{
    			alert("添加失败");
    		}
    	}
    	
    	function clearAdd(){
    		document.getElementById("biName").value = "";
    	}
	</script>
</head>
<body style="overflow-y:scroll;">
	<h2 class="title">品牌信息相关操作</h2>
	<div class="clear"></div>
	<hr class="dashed" />
	<div class="clear"></div>
	<table width="100%" border="0" class="round-table">
		<tr>
			<td class="l-t"></td>
			<td class="m-t"></td>
			<td class="r-t"></td>
		</tr>
		<tr>
			<td class="l-m"></td>
			<td>
				<table class="input-table">
					<tr>
						<td width="30%" class="right">品牌名称：</td>
						<td width="70%"><div class="input-bg" style="left">
								<input name="biName" type="text" id="biName" maxlength="100" />
							</div>
						</td>
					</tr>
					<tr>
						<td colspan="3" class="center"><a class="table-btn"
							onclick="selectInfo2()" id="select">查询<a class="table-btn"
							onclick="addInfo()" id="add">添加 <a class="table-btn"
								onclick="clearAdd()">重置</a> 
						</td>
					</tr>
				</table></td>
			<td class="r-m"></td>
		</tr>
		<tr>
			<td class="l-b"></td>
			<td class="m-b"></td>
			<td class="r-b"></td>
		</tr>
	</table>
	
	<div id="showDiv" style="display:none;">
	       <div style="width:96%; margin:auto;">
				<h2 class="title" style="margin-left:0px;">品牌明细</h2>
	        </div>
	        <div class="clear"></div>
	        <hr class="solid" />
        </div>
        <div id="container" style="margin-left:22px;margin-right:22px">
				<div id="demo">
	               
				</div>	
			<div class="spacer"></div>
		</div>
</body>
</html>
